<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php $this->load->view('bm/common/header'); ?>
<body>
<!-- 头部 -->
<?php $this->load->view('bm/common/top'); ?>
<!-- /头部 -->

<!-- 边栏 -->
<?php $this->load->view('bm/common/sidebar'); ?>
<!-- /边栏 -->

<!-- 内容区 -->
<div id="main-content">
	<div id="top-alert" class="fixed alert alert-error" style="display: none;">
		<button class="close fixed" style="margin-top: 4px;">&times;</button>
		<div class="alert-content">这是内容</div>
	</div>
	<div id="main" class="main">

		<!-- nav -->
		<!-- nav -->

		<!-- 标题 -->
		<div class="main-title">
			<h2>
				文档列表(1) [
				<a href="/index.php?s=/admin/article/index/cate_id/1.html">博客</a>
				<i class="ca"></i><a href="/index.php?s=/admin/article/index/cate_id/2.html">默认分类</a>]
			</h2>
		</div>

		<!-- 按钮工具栏 -->
		<div class="cf">
			<div class="fl">
				<div class="btn-group">
					<button class="btn document_add" url="<?php echo base_url('/bm/post/create');?>">新 增</button>
				</div>
				<button class="btn ajax-post" target-form="ids" url="/index.php?s=/admin/article/setstatus/status/1.html">启 用</button>
				<button class="btn ajax-post" target-form="ids" url="/index.php?s=/admin/article/setstatus/status/0.html">禁 用</button>
				<button class="btn ajax-post" target-form="ids" url="/index.php?s=/admin/article/move.html">移 动</button>
				<button class="btn ajax-post" target-form="ids" url="/index.php?s=/admin/article/copy.html">复 制</button>
				<button class="btn ajax-post" target-form="ids" hide-data="true" url="/index.php?s=/admin/article/paste.html">粘 贴</button>
				<input type="hidden" class="hide-data" name="cate_id" value="2"/>
				<input type="hidden" class="hide-data" name="pid" value="0"/>
				<button class="btn ajax-post confirm" target-form="ids" url="/index.php?s=/admin/article/setstatus/status/-1.html">删 除</button>

				<button class="btn document_add" url="/index.php?s=/admin/article/batchoperate/cate_id/2/pid/0.html">导入</button>
			</div>

			<!-- 高级搜索 -->
			<div class="search-form fr cf">
				<div class="sleft">
					<div class="drop-down">
						<span id="sch-sort-txt" class="sort-txt" data="">所有</span>
						<i class="arrow arrow-down"></i>
						<ul id="sub-sch-menu" class="nav-list hidden">
							<li><a href="javascript:;" value="">所有</a></li>
							<li><a href="javascript:;" value="1">正常</a></li>
							<li><a href="javascript:;" value="0">禁用</a></li>
							<li><a href="javascript:;" value="2">待审核</a></li>
						</ul>
					</div>
					<input type="text" name="title" class="search-input" value="" placeholder="请输入标题文档">
					<a class="sch-btn" href="javascript:;" id="search" url="/index.php?s=/admin/article/index/pid/0/cate_id/2"><i class="btn-search"></i></a>
				</div>
				<div class="btn-group-click adv-sch-pannel fl">
					<button class="btn">高 级<i class="btn-arrowdown"></i></button>
					<div class="dropdown cf">
						<div class="row">
							<label>更新时间：</label>
							<input type="text" id="time-start" name="time-start" class="text input-2x" value="" placeholder="起始时间" /> -
							<input type="text" id="time-end" name="time-end" class="text input-2x" value="" placeholder="结束时间" />
						</div>
						<div class="row">
							<label>创建者：</label>
							<input type="text" name="nickname" class="text input-2x" value="" placeholder="请输入用户名">
						</div>
					</div>
				</div>
			</div>
		</div>

		<!-- 数据表格 -->
		<div class="data-table">
			<table>
				<!-- 表头 -->
				<thead>
				<tr>
					<th class="row-selected row-selected">
						<input class="check-all" type="checkbox">
					</th>
					<th>编号</th><th>标题</th><th>类型</th><th>优先级</th><th>最后更新</th><th>状态</th><th>浏览</th><th>操作</th>                </tr>
				</thead>

				<!-- 列表 -->
				<tbody>
				<?php foreach ($list as $item => $value) { ?>
					<tr>
						<td><input class="ids" type="checkbox" value="102" name="ids[]"></td>
						<td><?php echo $value['id'];?></td>
						<td><a href="#"><?php echo $value['title'];?></a></td>
						<td><?php echo $value['category_title'];?></td>
						<td>0</td>
						<td><?php echo $value['create_time'];?></td>
						<td>正常</td>
						<td>0</td>
						<td><a href="<?php echo base_url('/bm/post/update/id/'.$value['id'].'.html');?>">编辑</a> <a href="/index.php?s=/admin/article/setstatus/status/-1/ids/102.html">删除</a></td>
					</tr>
				<?php } ?>
				</tbody>
			</table>
		</div>
		<!-- 分页 -->
		<div class="page">
			<div><?php echo $this->pagination->create_links();?></div>
		</div>
	</div>


</div>
<div class="cont-ft">
	<?php $this->load->view('bm/common/copyright'); ?>
</div>
</div>
<!-- /内容区 -->
<script type="text/javascript">
	(function(){
		var ThinkPHP = window.Think = {
			"ROOT"   : "", //当前网站地址
			"APP"    : "/index.php?s=", //当前项目地址
			"PUBLIC" : "/Public", //项目公共目录地址
			"DEEP"   : "/", //PATHINFO分割符
			"MODEL"  : ["3", "1", "html"],
			"VAR"    : ["m", "c", "a"]
		}
	})();
</script>
<script type="text/javascript" src="/static/think.js"></script>
<script type="text/javascript" src="/static/admin/js/common.js"></script>
<script type="text/javascript">
	+function(){
		var $window = $(window), $subnav = $("#subnav"), url;
		$window.resize(function(){
			$("#main").css("min-height", $window.height() - 130);
		}).resize();

		/* 左边菜单高亮 */
		url = window.location.pathname + window.location.search;
		url = url.replace(".html", "")
			.replace(/(\/(p)\/\d+)|(&p=\d+)|(\/(id)\/\d+)|(&id=\d+)/, "");
		$subnav.find("a[href^='" + url + "']").parent().addClass("current");

		/* 左边菜单显示收起 */
		$("#subnav").on("click", "h3", function(){
			var $this = $(this);
			$this.find(".icon").toggleClass("icon-fold");
			$this.next().slideToggle("fast").siblings(".side-sub-menu:visible").
			prev("h3").find("i").addClass("icon-fold").end().end().hide();
		});

		$("#subnav h3 a").click(function(e){e.stopPropagation()});

		/* 头部管理员菜单 */
		$(".user-bar").mouseenter(function(){
			var userMenu = $(this).children(".user-menu ");
			userMenu.removeClass("hidden");
			clearTimeout(userMenu.data("timeout"));
		}).mouseleave(function(){
			var userMenu = $(this).children(".user-menu");
			userMenu.data("timeout") && clearTimeout(userMenu.data("timeout"));
			userMenu.data("timeout", setTimeout(function(){userMenu.addClass("hidden")}, 100));
		});

		/* 表单获取焦点变色 */
		$("form").on("focus", "input", function(){
			$(this).addClass('focus');
		}).on("blur","input",function(){
			$(this).removeClass('focus');
		});
		$("form").on("focus", "textarea", function(){
			$(this).closest('label').addClass('focus');
		}).on("blur","textarea",function(){
			$(this).closest('label').removeClass('focus');
		});

		// 导航栏超出窗口高度后的模拟滚动条
		var sHeight = $(".sidebar").height();
		var subHeight  = $(".subnav").height();
		var diff = subHeight - sHeight; //250
		var sub = $(".subnav");
		if(diff > 0){
			$(window).mousewheel(function(event, delta){
				if(delta>0){
					if(parseInt(sub.css('marginTop'))>-10){
						sub.css('marginTop','0px');
					}else{
						sub.css('marginTop','+='+10);
					}
				}else{
					if(parseInt(sub.css('marginTop'))<'-'+(diff-10)){
						sub.css('marginTop','-'+(diff-10));
					}else{
						sub.css('marginTop','-='+10);
					}
				}
			});
		}
	}();
</script>

<link href="/static/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<link href="/static/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">
<link href="/static/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
	$(function(){
		//搜索功能
		$("#search").click(function(){
			var url = $(this).attr('url');
			var status = $("#sch-sort-txt").attr("data");
			var query  = $('.search-form').find('input').serialize();
			query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
			query = query.replace(/^&/g,'');
			if(status != ''){
				query += 'status=' + status + "&" + query;
			}
			if( url.indexOf('?')>0 ){
				url += '&' + query;
			}else{
				url += '?' + query;
			}
			window.location.href = url;
		});

		/* 状态搜索子菜单 */
		$(".search-form").find(".drop-down").hover(function(){
			$("#sub-sch-menu").removeClass("hidden");
		},function(){
			$("#sub-sch-menu").addClass("hidden");
		});
		$("#sub-sch-menu li").find("a").each(function(){
			$(this).click(function(){
				var text = $(this).text();
				$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
				$("#sub-sch-menu").addClass("hidden");
			})
		});

		//只有一个模型时，点击新增
		$('.document_add').click(function(){
			var url = $(this).attr('url');
			if(url != undefined && url != ''){
				window.location.href = url;
			}
		});

		//回车自动提交
		$('.search-form').find('input').keyup(function(event){
			if(event.keyCode===13){
				$("#search").click();
			}
		});

		$('#time-start').datetimepicker({
			format: 'yyyy-mm-dd',
			language:"zh-CN",
			minView:2,
			autoclose:true
		});

		$('#time-end').datetimepicker({
			format: 'yyyy-mm-dd',
			language:"zh-CN",
			minView:2,
			autoclose:true
		});
	})
</script>

</body>
</html>
